﻿#region Header
// ------------------------ Licence / Copyright ------------------------
// 
// ScrumTable for Scrum Meeting Support
// Copyright © HSR - Hochschule für Technik Rapperswil
// All Rights Reserved
// 
// Author:
//  Michael Gfeller Silvan Gehrig Patrick Boos
// 
// ---------------------------------------------------------------------
#endregion

#region Usings

using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using ScrumTable.Common.Collections;

#endregion


namespace ScrumTable.Config.ElementManagement
{
    /// <summary>
    /// Contains the config for a single view (target) and there default implementation
    /// </summary>
    [Serializable]
    public class TargetConfig
    {
        /// <summary>
        /// Targetname
        /// </summary>
        [XmlAttribute]
        public string TargetName { get; set; }

        /// <summary>
        /// All types which are shown in the view (like task, story...)
        /// </summary>
        [XmlArray("ShowTypes")]
        [XmlArrayItem(Type = typeof(string), ElementName = "Entry")]
        public List<string> ShowTypes { get; set; }


        /// <summary>
        /// Exclude states like ToVerfiy 
        /// </summary>
        [XmlArray("ExcludedStates")]
        [XmlArrayItem(Type = typeof(int), ElementName = "Entry")]
        public List<int> ExcludedStates { get; set; }

        /// <summary>
        /// If true = only items from the current iteration
        /// if false = all items (iterations + project)
        /// </summary>
        public bool IsCurrentIteration { get; set; }

        /// <summary>
        /// true = show bugs; false = show no bugs
        /// </summary>
        [XmlIgnore]
        public bool IsBug
        {
            get { return ShowTypes.Contains("Bug"); }
        }

        /// <summary>
        /// true = show Story; false = show no Story
        /// </summary>
        [XmlIgnore]
        public bool IsStory
        {
            get { return ShowTypes.Contains("Story"); }
        }

        /// <summary>
        /// true = show Task; false = show no Task
        /// </summary>
        [XmlIgnore]
        public bool IsTask
        {
            get { return ShowTypes.Contains("Task"); }
        }

        /// <summary>
        /// default constructor
        /// </summary>
        public TargetConfig()
        {
        }

        /// <summary>
        /// Gets the default config
        /// </summary>
        /// <param name="target"></param>
        /// <returns></returns>
        public static TargetConfig GetDefaultConfig(string target)
        {
            TargetConfig config;
            switch (target)
            {
                case "DailyScrumStoryBoard":
                    config = new TargetConfig
                                 {
                                     TargetName = "DailyScrumStoryBoard",
                                     ShowTypes = new List<string> {"Story", "Bug"},
                                     ExcludedStates = new List<int>(),
                                     IsCurrentIteration = true
                                 };

                    break;
                case "DailyScrumTaskBoard":
                    config = new TargetConfig
                                 {
                                     TargetName = "DailyScrumTaskBoard",
                                     ShowTypes = new List<string> {"Task", "Bug"},
                                     ExcludedStates = new List<int>(),
                                     IsCurrentIteration = true
                                 };
                    break;
                case "DailyScrumBoard":
                    config = new TargetConfig
                                 {
                                     TargetName = "DailyScrumBoard",
                                     ShowTypes = new List<string> {"Task", "Bug"},
                                     ExcludedStates = new List<int>(),
                                     IsCurrentIteration = true
                                 };
                    break;
                case "DailyScrumIndividualReport":
                    config = new TargetConfig
                    {
                        TargetName = "DailyScrumIndividualReport",
                        ShowTypes = new List<string>{ "Task", "Bug" },
                        ExcludedStates = new List<int>(),
                        IsCurrentIteration = true
                    };
                    break;
                default:
                    throw new NotSupportedException(target);
            }
            return config;
        }
    }
}
